﻿@model VisaApp.Models.QuocGiaModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestCategoeyChauLuc"
    };
}

<script type="text/javascript">

    function completedAjaxRequestCategoeyChauLuc(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            if (returnObj.Message != null) {
                makeSuccessHighlightChauLuc(returnObj.Message);
            }
            else if (returnObj.RedirectUrl != null) {
                window.location.href = returnObj.RedirectUrl;
            }
        } else {
            makeErrorHighlightChauLuc(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightChauLuc(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span><strong>Alert: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $highlight.delay(4000).fadeOut(500);
    }

    function makeSuccessHighlightChauLuc(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong>Success: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $highlight.delay(4000).fadeOut(500);
    }

    $(document).ready(function () {
        $(".rich-text").cleditor({ width: 496, height: 400, useCSS: true });
        $("#tabasAddCategory").tabs();

        var regioncodes = $("#regioncode").val();
        $("#selectKhuVucCode option").each(function () {
            if ($(this).val() == regioncodes) {
                $(this).attr("selected", "selected");
                return;
            }
        });

    });

    function onSelectlistCategoryCode() {
        var ids = $("#selectKhuVucCode").val();
        $("#regioncode").val(ids);
    }


</script>
@using (Ajax.BeginForm("EditQuocGia", "Quantri", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <div class="section-header">
        <div class="options">
            <button type="submit" name="save" value="save" class="t-button">
                Save</button>
        </div>
    </div>
    <div id="tabasAddCategory">
        <ul>
            <li><a href="#tabs-1">Thông tin</a></li>
            <li><a href="#tabs-2">Seo</a></li>
        </ul>
        <div id="tabs-1">
            <table>
                <tr>
                    <td colspan="2">
                        @Html.HiddenFor(model => model.Id, new { id = "Id" })
                        @Html.HiddenFor(model => model.DateCreate)
                        @Html.HiddenFor(model => model.Detele)
                        @Html.HiddenFor(model => model.regioncode, new { id = "regioncode" })
                        <div class="warning-area">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Name, "Tên châu lục"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.Name, new { @style = "width:300px" })
                        @Html.ValidationMessageFor(model => model.Name)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.countrycode, "Country Code"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.countrycode, new { @style = "width:300px" })
                        @Html.ValidationMessageFor(model => model.countrycode)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.regioncode, "Region Code"):
                    </td>
                    <td class="adminData">
                        <select id="selectKhuVucCode" onchange="onSelectlistCategoryCode()">
                            <option value="100">-- Chọn châu lục --</option>
                            <option value="142">Châu Á</option>
                            <option value="150">Châu Âu</option>
                            <option value="009">Châu Đại Dương</option>
                            <option value="002">Châu Phi</option>
                            <option value="019">Bắc Mỹ</option>
                            <option value="300">Nam Mỹ</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.alpha2, "alpha2 Code"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.alpha2, new { @style = "width:300px" })
                        @Html.ValidationMessageFor(model => model.alpha2)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.alpha3, "alpha3 Code"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.alpha3, new { @style = "width:300px" })
                        @Html.ValidationMessageFor(model => model.alpha3)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.iso31662, "iso31662 Code"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.iso31662, new { @style = "width:300px" })
                        @Html.ValidationMessageFor(model => model.iso31662)
                    </td>
                </tr>
                 <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.subregioncode, "Sub Region Code"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.subregioncode, new { @style = "width:300px" })
                        @Html.ValidationMessageFor(model => model.subregioncode)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Description, " Mô tả ngắn "):
                    </td>
                    <td class="adminData">
                        @Html.TextAreaFor(model => model.Description, new { @class="rich-text", @style = "width:300px; height:80px" })
                        @Html.ValidationMessageFor(model => model.Description)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Status, "Trạng thái hiển thị"):
                    </td>
                    <td class="adminData">
                        @Html.EditorFor(x => x.Status)
                        @Html.ValidationMessageFor(model => model.Status)
                    </td>
                </tr>
            </table>
        </div>
        <div id="tabs-2">
            <table>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.MetaTitle, "Meta Title"):
                    </td>
                    <td class="adminData">
                        @Html.TextAreaFor(model => model.MetaTitle, new { @style = "width:300px; height:50px" })
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Keywork, "Meta keywrok"):
                    </td>
                    <td class="adminData">
                        @Html.TextAreaFor(model => model.Keywork, new { @style = "width:300px; height:50px" })
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.metaDescription, " Meta Description"):
                    </td>
                    <td class="adminData">
                        @Html.TextAreaFor(model => model.metaDescription, new { @style = "width:300px; height:100px" })
                    </td>
                </tr>
            </table>
        </div>
    </div>
    
}
